import Blockly from 'blockly/core'
import 'blockly/python_compressed'
import 'blockly/blockly_compressed'
import 'blockly/blocks_compressed'

Blockly.Blocks.parse_int = {
  init: function () {
    this.appendValueInput('parsingState')
      .setCheck(null)
      .setAlign(Blockly.ALIGN_RIGHT)
      .appendField('int')
    this.setInputsInline(false)
    this.setOutput(true, 'Number')
    this.setColour(15)
    this.setTooltip('')
    this.setHelpUrl('')
  }
}

// 代码格式：int(statement)
Blockly.Python.parse_int = function (block) {
  const valueParsingState = Blockly.Python.valueToCode(
    block,
    'parsingState',
    Blockly.Python.ORDER_NONE
  )
  const code = 'int(' + valueParsingState + ')'
  return [code, Blockly.Python.ORDER_NONE]
}

export default Blockly
